package 所有的题类.ZA.链表;

import com.kiwi.nixu.common.LNode;

import java.util.Arrays;
import java.util.List;

public class 排序链表 {

    public static void main(String[] args) {
        LNode lNode = arrayToLNode(Arrays.asList(1,2,6,3,4,5,6));
    }
    public LNode sortList(LNode head) {

        return null;
    }

    public LNode digui(LNode head,LNode tail){

        LNode mid=getMid(head,tail);
        LNode mid1=getMid(mid.next,null);

        return null;
    }

    /*
     *找中间节点
     */
    public LNode getMid(LNode head,LNode tail){
        if(head==tail){
            return head;
        }
        LNode fast=head;
        LNode slow=head;
        while(fast!=tail){
            fast=fast.next.next;
            slow=slow.next;
        }
        return slow;
    }

    public static LNode arrayToLNode(List<Integer> list){
        LNode lNode = new LNode(list.get(0));
        LNode cur=lNode;
        for (int i = 1; i < list.size(); i++) {
            LNode tmp=new LNode(list.get(i));
            cur.next=tmp;
            cur=tmp;
        }
        return lNode;
    }
}
